{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-3">	
	<div class="layui-card">
		<div class="body-table layui-tab layui-tab-brief" lay-filter="tab">
			<ul class="layui-tab-title">
				<li class="layui-this">全部</li>
				<li>待我审批</li>
				<li>我已审批</li>
			</ul>
			<div class="layui-tab-content" style="padding:0">
				<table class="layui-hide" id="test" lay-filter="test"></table>
			</div>
		</div> 
	</div> 
</div>
<script type="text/html" id="toolbarDemo">
<h3 class="h3-title" style="height:28px;">审批列表</h3>
</script>						
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function gouguInit() {
		var table = layui.table, tool = layui.tool ,element=layui.element;
			
		element.on('tab(tab)', function(data){
			layui.pageTable.reload({where:{status:data.index},page:{curr:1}});
			return false;
		});			
			
		layui.pageTable = table.render({
			elem: '#test'
			,toolbar: '#toolbarDemo'
			,title:'审批列表'
			,url: "/oa/approve/list"
			,page: true //开启分页
			,limit: 20
			,cellMinWidth: 60
			,cols: [[
					{field:'id',width:80, title: 'ID号', align:'center'}
					,{field:'name',title: '申请人',width:90,align:'center'}
					,{field:'create_time',title: '申请时间',width:132,align:'center'}
					,{field:'flow_type',title: '审批类型',width:100, align:'center'}
					,{field:'department_name',title: '所属部门',width:100,align:'center'}
					,{field:'check_user',title: '当前审批人'}
					,{field:'check_status', title: '审批状态',width:80,align:'center',templet: function(d){
						var htmlArray = ['<span style="color:#666666">待审批</span>','<span style="color:#4285f4">审批中</span>','<span style="color:#34a853">已通过</span>','<span style="color:#FF5722">已拒绝</span>','<span style="color:#fbbc05">已撤销</span>'];
						return htmlArray[d.check_status];
					}}
					,{width:60,title: '操作', align:'center',templet: function(d){
						var btn='<a class="layui-btn layui-btn-xs" lay-event="view">详情</a>';
						return btn;
					}}
				]]
			});
			
			table.on('tool(test)',function (obj) {
				if(obj.event === 'view'){		
					tool.side('/oa/approve/view?id='+obj.data.id);
				}
			});
		}
	</script>
{/block}
<!-- /脚本 -->